import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

export const routes = [
  {
    path: '/',
    component: () => import('@/views/Login/index.vue'),
    hidden: true
  },
  {
    path: '/login',
    component: () => import('@/views/Login'),
    hidden: true
  },
  {
    path: '/home',
    redirect: 'home',
    component: (resolve) => require(['@/views/Home'], resolve),
    children: [
      {
        path: '/saomaShow',
        name: 'SaomaShow',
        component: (resolve) => require(['@/views/Saoma/SaomaShow'], resolve),
        meta: {
          title: '扫码'
        }
      },
      {
        path: '/task',
        name: 'Task',
        component: (resolve) => require(['@/views/Task'], resolve),
        meta: {
          title: '任务'
        }
      },
      {
        path: '/incomingInspection',
        name: 'IncomingInspection',
        component: (resolve) =>
          require(['@/views/Task/IncomingInspection'], resolve),
        meta: {
          title: '来料检'
        }
      },
      {
        path: '/incomingCheckInput',
        name: 'IncomingCheckInput',
        component: (resolve) =>
          require(['@/views/Task/IncomingInspection/IncomingCheckInput'], resolve),
        meta: {
          title: '来料检检验录入'
        }
      },
      {
        path: '/incomingCheckInputDetails',
        name: 'IncomingCheckInputDetails',
        component: (resolve) =>
          require(['@/views/My/IncomingInspectionDetails/IncomingCheckInputDetails'], resolve),
        meta: {
          title: '来料检验查询'
        }
      },
      {
        path: '/firstInspection',
        name: 'FirstInspection',
        component: (resolve) =>
          require(['@/views/Task/FirstInspection'], resolve),
        meta: {
          title: '首检'
        }
      },
      {
        path: '/firstCheckInput',
        name: 'FirstCheckInput',
        component: (resolve) =>
          require(['@/views/Task/FirstInspection/FirstCheckInput'], resolve),
        meta: {
          title: '首检检验录入'
        }
      },
      {
        path: '/patrolInspection',
        name: 'PatrolInspection',
        component: (resolve) =>
          require(['@/views/Task/PatrolInspection'], resolve),
        meta: {
          title: '巡检'
        }
      },
      {
        path: '/processInspection',
        name: 'ProcessInspection',
        component: (resolve) =>
          require(['@/views/Task/ProcessInspection'], resolve),
        meta: {
          title: '工序检'
        }
      },
      {
        path: '/processCheckInput',
        name: 'ProcessCheckInput',
        component: (resolve) =>
          require(['@/views/Task/ProcessInspection/ProcessCheckInput'], resolve),
        meta: {
          title: '工序检录入'
        }
      },
      {
        path: '/finishedProInspection',
        name: 'FinishedProInspection',
        component: (resolve) =>
          require(['@/views/Task/FinishedProInspection'], resolve),
        meta: {
          title: '成品检'
        }
      },
      {
        path: '/finishedProCheckInput',
        name: 'FinishedProCheckInput',
        component: (resolve) =>
          require(['@/views/Task/FinishedProInspection/FinishedProCheckInput'], resolve),
        meta: {
          title: '成品检录入'
        }
      },
      {
        path: '/my',
        name: 'My',
        component: (resolve) =>
          require(['@/views/My'], resolve),
        meta: {
          title: '我的'
        }
      },
      {
        path: '/firstInspectionRecord',
        name: 'FirstInspectionRecord',
        component: (resolve) =>
          require(['@/views/My/FirstInspectionRecord'], resolve),
        meta: {
          title: '首检记录查询'
        }
      },
      {
        path: '/firstCheckDetails',
        name: 'FirstCheckDetails',
        component: (resolve) =>
          require(['@/views/My/FirstInspectionRecord/FirstCheckDetails'], resolve),
        meta: {
          title: '首检记录详情'
        }
      },
      {
        path: '/patrolInspectionRecord',
        name: 'PatrolInspectionRecord',
        component: (resolve) =>
          require(['@/views/My/PatrolInspectionRecord'], resolve),
        meta: {
          title: '巡检记录查询'
        }
      },
      {
        path: '/patrolCheckDetails',
        name: 'PatrolCheckDetails',
        component: (resolve) =>
          require(['@/views/My/PatrolInspectionRecord/PatrolCheckDetails'], resolve),
        meta: {
          title: '巡检记录详情'
        }
      },
      {
        path: '/processInspectionRecord',
        name: 'ProcessInspectionRecord',
        component: (resolve) =>
          require(['@/views/My/ProcessInspectionRecord'], resolve),
        meta: {
          title: '工序检记录查询'
        }
      },
      {
        path: '/processCheckDetails',
        name: 'ProcessCheckDetails',
        component: (resolve) =>
          require(['@/views/My/ProcessInspectionRecord/ProcessCheckDetails'], resolve),
        meta: {
          title: '工序检记录详情'
        }
      },
      {
        path: '/finalInspectionRecord',
        name: 'FinalInspectionRecord',
        component: (resolve) =>
          require(['@/views/My/FinalInspectionRecord'], resolve),
        meta: {
          title: '成品检记录查询'
        }
      },
      {
        path: '/incomingInspectionDetails',
        name: 'IncomingInspectionDetails',
        component: (resolve) =>
          require(['@/views/My/IncomingInspectionDetails'], resolve),
        meta: {
          title: '来料检记录查询'
        }
      },
      {
        path: '/finalCheckDetails',
        name: 'FinalCheckDetails',
        component: (resolve) =>
          require(['@/views/My/FinalInspectionRecord/FinalCheckDetails'], resolve),
        meta: {
          title: '成品检记录详情'
        }
      },
      {
        path: '/userDetails',
        name: 'UserDetails',
        component: (resolve) =>
          require(['@/views/My/UserDetails'], resolve),
        meta: {
          title: '基本信息'
        }
      },
      {
        path: '/saoma',
        name: 'Saoma',
        component: (resolve) =>
          require(['@/views/Saoma'], resolve),
        meta: {
          title: '扫码'
        }
      },
      {
        path: '/equipmentInspection',
        name: 'EquipmentInspection',
        component: (resolve) =>
          require(['@/views/Task/EquipmentInspection'], resolve),
        meta: {
          title: '设备点检'
        }
      },
      {
        path: '/equipmentCheckInput',
        name: 'EquipmentCheckInput',
        component: (resolve) =>
          require(['@/views/Task/EquipmentInspection/EquipmentCheckInput'], resolve),
        meta: {
          title: '点检录入'
        }
      },
      {
        path: '/repairRequest',
        name: 'RepairRequest',
        component: (resolve) =>
          require(['@/views/Task/RepairRequest'], resolve),
        meta: {
          title: '转维修'
        }
      },
      {
        path: '/applyAccessory',
        name: 'ApplyAccessory',
        component: (resolve) =>
          require(['@/views/Task/ApplyAccessory'], resolve),
        meta: {
          title: '申请配件'
        }
      },
      {
        path: '/eqRepair',
        name: 'EqRepair',
        component: (resolve) =>
          require(['@/views/Task/EqRepair'], resolve),
        meta: {
          title: '设备维修'
        }
      },
      {
        path: '/eqRepairRequest',
        name: 'EqRepairRequest',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/EqRepairRequest'], resolve),
        meta: {
          title: '维修申请'
        }
      },
      {
        path: '/repairAddInfo',
        name: 'RepairAddInfo',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/EqRepairRequest/RepairAddInfo'], resolve),
        meta: {
          title: '维修申请-新增编辑'
        }
      },
      {
        path: '/repairConfirm',
        name: 'RepairConfirm',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/EqRepairRequest/RepairConfirm'], resolve),
        meta: {
          title: '维修确认'
        }
      },
      {
        path: '/taskAssignment',
        name: 'TaskAssignment',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/EqRepairRequest/TaskAssignment'], resolve),
        meta: {
          title: '任务下达'
        }
      },
      {
        path: '/repairDetail',
        name: 'RepairDetail',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/EqRepairRequest/RepairDetail'], resolve),
        meta: {
          title: '维修单详情'
        }
      },
      {
        path: '/internalRepair',
        name: 'InternalRepair',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/InternalRepair'], resolve),
        meta: {
          title: '内修任务'
        }
      },
      {
        path: '/externalRepair',
        name: 'ExternalRepair',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/ExternalRepair'], resolve),
        meta: {
          title: '外修任务'
        }
      },
      {
        path: '/workReport',
        name: 'WorkReport',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/InternalRepair/WorkReport'], resolve),
        meta: {
          title: '内修报工'
        }
      },
      {
        path: '/workReportOut',
        name: 'WorkReport',
        component: (resolve) =>
          require(['@/views/Task/EqRepair/ExternalRepair/WorkReport'], resolve),
        meta: {
          title: '外修报工'
        }
      },
      {
        path: '/eqMaintain',
        name: 'EqMaintain',
        component: (resolve) =>
          require(['@/views/Task/EqMaintain'], resolve),
        meta: {
          title: '设备保养'
        }
      },
      {
        path: '/workReportBy',
        name: 'WorkReport',
        component: (resolve) =>
          require(['@/views/Task/EqMaintain/WorkReport'], resolve),
        meta: {
          title: '保养报工'
        }
      },
      {
        path: '/isolationProductDisposal',
        name: 'IsolationProductDisposal',
        component: (resolve) =>
          require(['@/views/Task/IsolationProductDisposal'], resolve),
        meta: {
          title: '隔离品处置'
        }
      },
      {
        path: '/processCard',
        name: 'ProcessCard',
        component: (resolve) =>
          require(['@/views/Task/ProcessCard'], resolve),
        meta: {
          title: '返修流程卡'
        }
      },
      {
        path: '/scrapInfo',
        name: 'ScrapInfo',
        component: (resolve) =>
          require(['@/views/Task/ScrapInfo'], resolve),
        meta: {
          title: '报废单'
        }
      },
            {
        path: '/repairAndRework',
        name: 'RepairAndRework',
        component: (resolve) =>
          require(['@/views/Task/RepairAndRework'], resolve),
        meta: {
          title: '返工返修检'
        }
      }
    ]
  }
]

const createRouter = () =>
  new VueRouter({
    mode: 'hash', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: routes
  })

const router = createRouter()

// 重置路由 (用户退出登录刷新路由)
export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router
